import request from '@/utils/request'
import {getToken} from "@/utils/auth";

export function login(res) {
  return request({
    url: '/api/admin/Login',
    method: 'post',
    params: res
  })
}

export function getInfo(token) {
  return request({
    url: '/api/admin/getUserInfo',
    method: 'post',
    params: { token },
    headers: {
      Token: getToken()
    }
  })
}

export function logout() {
  return request({
    url: '/api/admin/LoginOut',
    method: 'post'
  })
}

export function getUserList(search_name, search_role, page, limit) {
  return request({
    url: '/api/admin/getUserList',
    method: 'get',
    headers: {
      Token: getToken()
    },
    params:{'search_name':search_name,'search_role':search_role,'page':page,'limit':limit}
  })
}
export function CheckUserStatus(status,id) {
  return request({
    url: '/api/admin/CheckUserStatus',
    method: 'post',
    headers: {
      Token: getToken()
    },
    params:{'status':status,'id':id}
  })
}
export function deleteUser(id) {
  return request({
    url: '/api/admin/deleteUser',
    method: 'post',
    headers: {
      Token: getToken()
    },
    params:{'id':id}
  })
}
export function updateUser(res) {
  return request({
    url: '/api/admin/updateUser',
    method: 'post',
    params:res,
    headers: {
      Token: getToken()
    }
  })
}
export function addUser(res) {
  return request({
    url: '/api/admin/addUser',
    method: 'post',
    headers: {
      Token: getToken()
    },
    params:res
  })
}

export function GetRoleList() {
  return request({
    url: '/api/admin/GetRoleAll',
    method: 'get',
    headers: {
      Token: getToken()
    }
  })
}
